<?php if ($sf_user->hasFlash('save_category')){
?>		
			<div id="notification" class="nNote nSuccess hideit" onclick="$('#notification').hide('slow')" style="margin-top: 20px;">
                <p><strong>SUCCESS: </strong> <?php echo $sf_user->getFlash('save_category') ?></p>
         </div>

<?php 
}?>

<?php 
if (count($categories) > 0){
?>
<div class="widget" id="categories_div">

<?php
include_partial('category_level', array('categories' => $categories, 'selectedDirectoryId' => $selectedDirectoryId, 'selectedCategoryId' => $selectedCategoryId, 'directory' => $directory))?>


</div>



<form action="<?php echo url_for("category_content/saveCategoryContent")?>" method="post" class="mainForm" enctype="multipart/form-data" name="upload_form" id="upload_form">
	<div class="widget" id="categories_div">
		<div class="head"><h5 class="iList">Upload CSV File</h5></div>
		<div class="rowElem noborder">
		<div style="clear: both;">
			<div style="float: left; width: 570px">
				<label>CSV Path :</label> 
			     <div style="margin-top: 10px">
			          <input type="file" id="csv_file" class="fileInput" id="fileInput" name="fileInput" />
			     </div>			
			</div>
			<div style="float: left;margin-top: 10px">
	           <input type="button" value="Save" class="greyishBtn" onclick="if(!validate()){return false;}; jConfirm('Are you sure you want to upload the contents for <?php echo $directory->getName()?>, category: ' + $('#level_category_id option:selected').text()  +' ?', 'Confirmation Dialog', function(r){if (!r){return false} else {$('form#upload_form').submit()}});" />
			</div>
		</div>
		
    <div class="fix"></div>
	     </div>
	     
    </div>
    <input type="hidden" id="h_category_id" name="h_category_id" value="<?php echo $selectedCategoryId?>"/>
    
</form>

	<div id="error_msg" class="error_msg" style="clear:both; display: none; cursor:pointer;" onclick="$(this).hide('slow')">
		<div id="msg_text" ></div>
	</div>
	
<?php if($info_array != null){ ?>
<div class="widget" id="category_level_tree_div" style="float:left;min-height: 170px;min-width: 420px;">

		<div class="head"><h5 class="iList">Upload Results</h5></div>
		<div class="rowElem noborder">
		<?php
		$i = 1; 
		foreach ($info_array as $info_element){?>
		<div style="clear: both;">
			<div style="float: left; min-width: 48px">
				Level <?php echo $i++?>	
			</div>
			<div style="float: left;">
	          <?php echo '<b>' . $info_element . '</b>'?> records
			</div>
		</div>
		<?php }?>
		
	</div>
	</div>
<?php }?>


<script type="text/javascript">
function validate(){
	var valid = true;
	var error_msg = "";
	if ($("#csv_file").attr("value") == ""){
		valid = false;
		error_msg = "CSV file required";
	};	
		
	if (!valid){
		$('#msg_text').html(error_msg);
		$('#error_msg').show('fast');
	}
	return valid;			
}
</script>

<?php 
}
else{
	?>
	<div style="margin-top:40px">
	<i>There are no categories created</i>
	</div>	
<?php 
}

?>